public class test {
    public static void main(String[] args) {
      String str = "hello world";
      System.out.println(str.substring(5));
      System.out.println(str.substring(0,5));
    }
    public static void main4(String[] args) {
//格式化
            String s = String.format("%d-%d-%d", 2019, 9,14);
            System.out.println(s);
//字符串的替换
        String ch = "hello world Love you";
        System.out.println(ch.replaceFirst("e","a"));
        System.out.println(ch.replaceAll("l","k"));
        System.out.println(ch.replaceFirst("x","q"));
System.out.println("======================");
        String[] strings = ch.split(" ");//按空格拆分

        for (String x:strings){
            System.out.println(x);
        }
        System.out.println("=============");
        String[] ARR = ch.split(" ",2);//按空格分割成两组
        for (String i :ARR){
            System.out.println(i);
        }
    }
      public static void main3(String[] args) {


          String s = "hello";
// 字符串转数组
          char[] ch = s.toCharArray();
          for (int i = 0; i < ch.length; i++) {
              System.out.print(ch[i]);
          }
          System.out.println();
// 数组转字符串
          String s2 = new String(ch);
          System.out.println(s2);
          System.out.println("=================");
          String a2 = "hello world";
          char[] arrya = a2.toCharArray();
          for (char x : arrya) {
              System.out.println(x);
          }
          System.out.println(arrya);


      }

    public static void main2(String[] args) {
        // 数字转字符串
        String s1 = String.valueOf(1234);
        String s2 = String.valueOf(12.34);
        String s3 = String.valueOf(true);

        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);
        //字符串转化为数字
        // 注意：Integer、Double等是Java中的包装类型
        int a1 = Integer.parseInt("1234");
        double a2 = Double.parseDouble("12.34");

        System.out.println(a1);
        System.out.println(a2);
    }
    public static void main1(String[] args) {
        String s1 ="abcdef";
        String s2 = new String("abcdef hello");
        char []arryr = {'a','b','c'};
        String s4 = "aaabbbbccccdddd";
        String s3 = new String(arryr);
        System.out.println(s2.indexOf("acd"));
        System.out.println("================");
        System.out.println(s4.lastIndexOf('a'));
        System.out.println(s4.lastIndexOf('a',2));
        System.out.println("=========================");
        // 数字转字符串


    }
}
